home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / doors / multichatdoor / deletechatport.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-05  |  962 b   |  46 lines

  1. #include <exec/types.h>
  2. #include <exec/ports.h>
  3. #include <exec/memory.h>
  4. #include <dos/dos.h>
  5. #include <clib/exec_protos.h>
  6. #include <clib/alib_protos.h>
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include "MultiChat.h"
  10. #include <doorheader.h>
  11. #include "ChatMsg.h"
  12.  
  13. UWORD DeleteChatPort(void)
  14. {
  15.     struct MsgPort *ChatPort;
  16.     struct ChatMsgStruct *ChatMsg;
  17.  
  18.     extern char *PortNames[];
  19.     char        YourNode_char[200];
  20.     char        Buf[100];
  21.     
  22.     UWORD    NodeNr;
  23.  
  24.  
  25.     getuserstring(YourNode_char, BB_NODEID);
  26.     NodeNr = atoi(YourNode_char);
  27.  
  28.     if (ChatMsg = (struct ChatMsgStruct *)AllocMem(sizeof(struct ChatMsgStruct), MEMF_ANY | MEMF_CLEAR))
  29.     {
  30.         ChatPort = FindPort(PortNames[NodeNr]);
  31.  
  32.         while (ChatMsg = (struct ChatMsgStruct *)GetMsg(ChatPort))
  33.             ReplyMsg((struct Message *)ChatMsg);
  34.         DeletePort(ChatPort);
  35.  
  36.         FreeMem(ChatMsg, sizeof(struct ChatMsgStruct));
  37.     }
  38.     else
  39.     {
  40.         sprintf(Buf, "Couldn't allocate memory for msg structure.\r\n");
  41.         sendmessage(Buf, 0);
  42.     }
  43.     return(TRUE);
  44. }
  45.  
  46.